package com.fanrenqiji.entity;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.List;

/**
 * Created by yanwt on 2017/3/14.
 */
@Getter
@Setter
@Entity
@Table(name="tb_event_case")
@org.hibernate.annotations.Table(appliesTo = "tb_event_case",comment = "课程事件实例表")
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate
@org.hibernate.annotations.Cache(region="event_case", usage = CacheConcurrencyStrategy.READ_WRITE)
public class EventCaseEntity extends DataEntity{
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private Long id;
    @ManyToOne
    @JoinColumn(name="event_id",columnDefinition=("bigint(20) default null comment '事件ID'"))//,foreignKey = @ForeignKey(value=ConstraintMode.NO_CONSTRAINT))
    @Where(clause="del_flag="+DEL_FLAG_NORMAL)
    private EventEntity event;

    @Column(name = "task_file_url",columnDefinition="varchar(200) not null comment '任务文件地址'")
    private String taskFileUrl;

    @Column(name = "answer_file_url",columnDefinition="varchar(200) not null comment '答案文件地址'")
    private String answerFileUrl;
    @ManyToMany
    @JoinTable(name = "tb_course_event_case", joinColumns = {@JoinColumn(name = "event_case_id",columnDefinition=("bigint(20) not null comment '事件实例ID'"))}, inverseJoinColumns = {@JoinColumn(name = "course_id",columnDefinition=("bigint(20) not null comment '课程ID'"))})//,foreignKey = @ForeignKey(value=ConstraintMode.NO_CONSTRAINT),inverseForeignKey=@ForeignKey(value=ConstraintMode.NO_CONSTRAINT))
    @Where(clause="del_flag="+DEL_FLAG_NORMAL)
    private List<CourseEntity> courseEntities;
}
